<?php

/**
 * This is the model class for table "sh_quote_item".
 *
 * The followings are the available columns in table 'sh_quote_item':
 * @property string $item_id
 * @property string $quote_id
 * @property string $created_at
 * @property string $updated_at
 * @property string $product_id
 * @property string $name
 * @property string $description
 * @property string $qty
 * @property string $price
 * @property string $base_price
 * @property string $row_total
 * @property string $redirect_url
 * @property integer $status
 */
class QuoteItem extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return QuoteItem the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'sh_quote_item';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('status', 'numerical', 'integerOnly'=>true),
			array('quote_id, product_id', 'length', 'max'=>10),
			array('name, redirect_url', 'length', 'max'=>255),
			array('qty, price, base_price, row_total', 'length', 'max'=>16),
			array('created_at, updated_at, description', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('item_id, quote_id, created_at, updated_at, product_id, name, description, qty, price, base_price, row_total, redirect_url, status', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'item_id' => 'Item',
			'quote_id' => 'Quote',
			'created_at' => 'Created At',
			'updated_at' => 'Updated At',
			'product_id' => 'Product',
			'name' => 'Name',
			'description' => 'Description',
			'qty' => 'Qty',
			'price' => 'Price',
			'base_price' => 'Base Price',
			'row_total' => 'Row Total',
			'redirect_url' => 'Redirect Url',
			'status' => 'Status',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('item_id',$this->item_id,true);
		$criteria->compare('quote_id',$this->quote_id,true);
		$criteria->compare('created_at',$this->created_at,true);
		$criteria->compare('updated_at',$this->updated_at,true);
		$criteria->compare('product_id',$this->product_id,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('qty',$this->qty,true);
		$criteria->compare('price',$this->price,true);
		$criteria->compare('base_price',$this->base_price,true);
		$criteria->compare('row_total',$this->row_total,true);
		$criteria->compare('redirect_url',$this->redirect_url,true);
		$criteria->compare('status',$this->status);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}